package com.nbgroup.mapper;

import com.github.pagehelper.Page;
import com.nbgroup.pojo.Activity;
import com.nbgroup.pojo.Course;
import com.nbgroup.pojo.dto.PageActivityDTO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface ActivityMapper {
    /**
     * 搜索活动
     * @param pageActivityDTO
     * @return
     */
    Page<Activity> activityPageQuery(PageActivityDTO pageActivityDTO);

    /**
     * 添加活动
     * @param activity
     */
    void addActivity(Activity activity);

    /**
     * 修改活动
     * @param activity
     */
    void updateActivity(Activity activity);

    /**
     * 查询所有活动
     * @return
     */
    @Select("select * from activity")
    List<Activity> queryAllActivity();

    /**
     * 活动查询回显
     * @param id
     * @return
     */
    @Select("select * from activity where id=#{id}")
    Activity queryById(Long id);

    /**
     * 删除活动
     * @param id
     */
    @Delete("delete from activity where id=#{id}")
    void deleteActivity(Long id);

    /**
     * 根据渠道查询活动
     */
    @Select("select * from activity where channel=#{channel}")
    List<Course> queryByChannel(String channel);
}
